;--------------------------------------
;
; strcmp.asm
;
; compare source to dest string
;   if srce > dest, returns 1 to 
;      return_value
;   if srce = dest, returns 0 to 
;      return_value
;   if srce < dest, returns -1 to 
;      return_value
;

;--------------------------------------
;
; include defs, prototypes and macros
;

include tab6.inc

;--------------------------------------
;
; begin code segment
;

	.CODE

;--------------------------------------
;
; strcmp(value,number);
;
; strcmp requires that the
; PREPARE_STRING macro be utilized
; before strcmp is INVOKED
; 

strcmp	PROC PASCAL PUBLIC USES ds es si di,dest:PBYTE,srce:PBYTE

; initialize source

 IF mdl eq 3
	
; set dest es:[di]

        les     di,dest

; set srce ds:[si]

        lds     si,srce

  ELSE

        push    ds
        pop     es

; set dest es:[di]

        mov     di,srce

; set srce ds:[si]

        mov     si,srce

  ENDIF

	sub	bx,bx
	sub	ax,ax

	.WHILE 1
	mov	al,BYTE PTR ds:[si]    ; srce
	mov	bl,BYTE PTR es:[di]    ; dest
	.IF (al==0)
IF mdl eq 3
	push	ds
	push	si
	mov	ax,SEG return_value
	mov	ds,ax
	mov	si,OFFSET return_value
	mov	ax,0
	mov	WORD PTR ds:[si],ax
	pop	si
	pop	ds
ELSE
	mov	ax,0
	mov	return_value,ax
ENDIF
	
	ret
	.ENDIF
	.IF (al>bl)
IF mdl eq 3
	push	ds
	push	si
	mov	ax,SEG return_value
	mov	ds,ax
	mov	si,OFFSET return_value
	mov	ax,1
	mov	WORD PTR ds:[si],ax
	pop	si
	pop	ds
ELSE
	mov	ax,1
	mov	return_value,ax
ENDIF
	ret
	.ENDIF
	.IF (bl>al)
IF mdl eq 3
	push	ds
	push	si
	mov	ax,SEG return_value
	mov	ds,ax
	mov	si,OFFSET return_value
	mov	ax,-1
	mov	WORD PTR ds:[si],ax
	pop	si
	pop	ds
ELSE
	mov	ax,-1
	mov	return_value,ax
ENDIF
	ret
	.ENDIF
	inc	di
	inc	si
	.ENDW
	ret	                       ; return to caller
strcmp	ENDP

;
; end of strcmp procedure
;
;--------------------------------------

	END

;
; end of strcmp.asm
;
;--------------------------------------


